package com.example.operation.repairrecordinfo.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.operation.repairrecordinfo.entity.RepairRecordInfo;
import com.example.operation.repairrecordinfo.service.RepairRecordInfoService;
import com.example.substation.common.FrameResponse;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.servlet.ModelAndView;

/**
 * <p>
 * 报修记录信息表 前端控制器
 * </p>
 *
 * @author liqiang
 * @since 2021-11-01
 */
@RestController
@RequestMapping("/repairrecordinfo")
public class RepairRecordInfoController {

    private final RepairRecordInfoService repairRecordInfoService;

    public RepairRecordInfoController(RepairRecordInfoService repairRecordInfoService) {
        this.repairRecordInfoService = repairRecordInfoService;
    }

    /**
     * 分页查询
     * @param repairRecordInfo
     * @param page
     * @param limit
     * @return
     */
    @GetMapping("paging")
    public FrameResponse paging (@ModelAttribute RepairRecordInfo repairRecordInfo, @RequestParam int page, @RequestParam int limit) {
        return FrameResponse.success(repairRecordInfoService.paging(repairRecordInfo, page, limit));
    }

    /**
     * 根据id查询数据
     * @param id
     * @return
     */
    @GetMapping("{id}")
    public FrameResponse getById (@PathVariable("id") Integer id) {
        return FrameResponse.success(repairRecordInfoService.getById(id));
    }

    /**
     * 根据id删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public boolean del (@PathVariable("id") Integer id) {
        return repairRecordInfoService.removeById(id);
    }

    /**
     * 插入数据
     * @param repairRecordInfo
     * @return
     */
    @PostMapping("")
    public FrameResponse insert (@ModelAttribute RepairRecordInfo repairRecordInfo) {
        return FrameResponse.success(repairRecordInfoService.save(repairRecordInfo));
    }

    /**
     * 修改数据
     * @param repairRecordInfo
     * @return
     */
    @PutMapping("")
    public FrameResponse update (@ModelAttribute RepairRecordInfo repairRecordInfo) {
        return FrameResponse.success(repairRecordInfoService.updateById(repairRecordInfo));
    }

//    @GetMapping("list")
//    public ModelAndView index () {
//        return new ModelAndView("repair-record-info/repair_record_info_list");
//    }



}
